//快速排序
let arr = [49,38,65,97,76,13,27];

const Partition = (arr,low,high) => {
    let pivot = arr[low];
    while(low<high){
        while(arr[high] >= pivot && low < high) --high;
        arr[low] = arr[high];
        while(arr[low] <= pivot && low < high) ++low;
        arr[high] = arr[low];
    }
    arr[low] = pivot;
    return low;
}

const QuickSort = (arr,low,high) => {
    if(low < high){
        let pivot = Partition(arr,low,high);
        //arr[pivot] 是已经确定的值,不需要参与调整了
        QuickSort(arr,low,pivot-1);
        QuickSort(arr,pivot+1,high)
    }
}

QuickSort(arr,0,arr.length-1);
console.log(arr)